
#include "syscall.h"

#include <syscall.h>
#include <sys/reg.h>
#include <sys/user.h>
#include <sys/ptrace.h>



int syscall_get_code(pid_t pid)
{
#ifdef x86_64
	long code = ptrace(PTRACE_PEEKUSER, pid, 8* ORIG_RAX, NULL);
	return (int) code;
#elif defined(x386)
	long code = ptrace(PTRACE_PEEKUSER, pid, 4 * ORIG_EAX, NULL);
	return (int) code;
#endif
	return 0;
}


const char* syscall_name(int code)
{
	switch(code) {
	case SYS_open:	return "SYS_open";
	case SYS_close:	return "SYS_close";
	case SYS_read:	return "SYS_read";
	case SYS_write:	return "SYS_write";
	default:	return "Unknown syscall";
	};
}

